public class Exception {
    //空指针异常
    public static void main(String[] args) throws NullPointerException {
        try{
            int[] arr = null;

        System.out.println(arr[0]);
        }catch (NullPointerException x){
            System.out.println();
            System.out.println("空指针异常解除");
        }
    }
    //数组越界异常
    public static void main1(String[] args) throws ArrayIndexOutOfBoundsException{
        try
        {
            int[] arr = {1,2,3};

        System.out.println(arr[4]);
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println();
            System.out.println("数组越界异常解除！");
        }
    }
}
